﻿@model SoftHotel.Models.OrdenCompra

@{
    ViewBag.Title = "Agregar";
}

@using (Html.BeginForm())
{   
     @Html.ValidationSummary(true)
<h2>Agregar</h2>


<br />
<br />
    
<table id="MainContent_Table1" style="border-color: white; width: 900px; margin-bottom: 0px;" border="0" rules="none">
    <tr>
        <td style="font-weight: bold; width: 110px;">Proveedor</td>
        <td style="width: 451px;">
        @{
            
            @Html.DropDownListFor(modelItem => Model.Proveedor, (SelectList)ViewBag.Proveedores, "Seleccione")
            @Html.ValidationMessageFor(modelItem => Model.Proveedor)
        }
        </td>
        <td style="font-weight: bold;">Fecha de Entrega: </td>
        <td>@Html.TextBoxFor(Model => Model.FechaEntrega)
            @Html.ValidationMessageFor(modelItem => Model.FechaEntrega)
        </td>
    </tr>
    <tr>
        
        <td style="font-weight: bold;">Seleccione Hotel: </td>
        <td style="width: 450px;">
            @Html.DropDownListFor(Model => Model.Sede, (SelectListItem[])ViewBag.Hoteles, "Seleccione")
            @Html.ValidationMessageFor(Model => Model.Sede)
        </td>
        <td style="font-weight: bold;">Forma de Pago:</td>
        <td>
            @Html.DropDownListFor(modelItem => Model.FormaPago, (SelectListItem[])ViewBag.FormaPagos, "Seleccione")
            @Html.ValidationMessageFor(modelItem => Model.FormaPago)
        </td>
    </tr>
    <tr>
        <td style="font-weight: bold;">Moneda:</td>
        <td>
            @Html.DropDownListFor(Model => Model.Moneda, (SelectListItem[])ViewBag.Monedas, "Seleccione")
            @Html.ValidationMessageFor(Model => Model.Moneda)
        </td>
        <td style="font-weight: bold;"> Prioridad</td>
        <td>
            @Html.DropDownListFor(Model => Model.Prioridad, (SelectListItem[])ViewBag.Prioridades, "Seleccione")
            @Html.ValidationMessageFor(Model => Model.Prioridad)
        </td>
    </tr>
        <tr id="MainContent_TableRow1">
        <td style="font-weight: bold;"> </td>
        <td id="MainContent_TableCell3"> </td>
        <td style="font-weight: bold;"></td>
        <td></td>
    </tr>
</table>
<table id="MainContent_Table1" style="border-color: white; margin-bottom: 0px; width: 896px; height: 65px;" border="0" rules="none">
    <tr>
        <td style="font-weight: bold; width: 110px;"></td>
        <td style="width: 451px;"></td>
        <td style="width: 121px;"><span style="font-weight: bold;">Total</span></td>
        <td style="width: 200px;">S./ @Html.TextBoxFor(Model => Model.total, new { disabled = "disabled" })</td>
    </tr>
</table>
<br />
<font size="3">
ARTICULOS
<br />
<br />
</font> 
<script type="text/javascript">
    $('#Proveedor').change(function () {
        var provSeleccionado = $(this).val();
        if (provSeleccionado != null && provSeleccionado != '') {
            $.getJSON('@Url.Action("Models")', { prov: provSeleccionado }, function (productos) {
                var monthsSelect = $('#nombreProducto');
                monthsSelect.empty();
                $.each(productos, function (index, producto) {
                    monthsSelect.append($('<option/>', {
                        value: producto.value,
                        text: producto.text

                    }));
                });
            });
        }
    });
</script>
<table id="MainContent_Table3" style="background-color: rgb(189, 189, 189); margin-bottom: 0px; width: 900px; height: 24px;" border="0" rules="all">
    <tr>
      <td> 
         <strong>Articulo:</strong>
         @Html.DropDownListFor(Model => Model.nombreProducto, Enumerable.Empty<SelectListItem>(), "Seleccione")
         <strong>Cantidad:</strong>
         @Html.TextBoxFor(Model => Model.cantidadProducto)
         <strong>Precio:</strong>
         @Html.TextBoxFor(Model => Model.precioProducto)
         <input name="button" value="Añadir"  style="height: 23px;" type="submit" />
         <input name="button" value="Eliminar"  style="height: 23px;" type="submit" />
       </td>
    </tr>
</table>
<br />
<table id="MainContent_Table2" style="border-color: Black; width: 900px; margin-bottom: 0px;" border="1" rules="all">
    <tr>
        <td style="font-weight: bold; width: 350px;" align="center">Descripcion</td>
        <td style="font-weight: bold; width: 150px;" align="center">Costo Unitario (S./)</td>
        <td style="font-weight: bold; width: 110px;" align="center">Cantidad</td>
        <td style="font-weight: bold; width: 110px;" align="center">Total(S/.)</td>
        <td style="font-weight: bold; width: 15px;" align="center"></td>
    </tr> 
    @{
    foreach (var prod in (System.Collections.Generic.List<SoftHotel.Models.ProductoModel>)ViewBag.listaProductos)
    {
                <tr>
                <td> @prod.descripcion</td>
                <td align="center">@prod.precio</td>
                <td align="center">@prod.cantidad</td>
                <td align="center">@prod.total</td>
                <td align="center"><a href = "/Producto/Editar2?descripcion=@prod.idProducto"><img border="0" src="@Href("~/Content/Images/delete.jpg")"></a></td>
                </tr>
        
    }
    }
   
</table>
    
<br />
<center>
    <input value="Guardar" type="submit" name = "button" />
    <input value="Cancelar" type="submit" name = "button"/>
</center> 
<br />
<br />
    
}